package com.zzjson.design.proxy.my.custom;


import com.zzjson.design.proxy.my.custom.proxy.MyClassLoader;
import com.zzjson.design.proxy.my.custom.proxy.MyInvocationHandler;
import com.zzjson.design.proxy.my.custom.proxy.MyProxy;

import java.lang.reflect.Method;

/**
 * <p>****************************************************************************</p>
 * <p><b>Copyright © 2010-2018 rollBall team All Rights Reserved<b></p>
 * <ul style="margin:15px;">
 * <li>Description : cn.zzjson.design.proxy.my</li>
 * <li>Version     : 1.0.0</li>
 * <li>Creation    : 2018年12月01日</li>
 * <li>@author     : zzy0_0</li>
 * </ul>
 * <p>****************************************************************************</p>
 */
public class MeiPo implements MyInvocationHandler {
    private Person target;

    public Object getInstance(Person target) {
        this.target = target;
        Class clazz = target.getClass();
        return MyProxy.newProxyInstance(new MyClassLoader(), clazz.getInterfaces(), this);
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        System.out.println("要求多");
        //target.findLove();
        method.invoke(this.target, args);
        System.out.println("要求多");
        return null;
    }
}